<?php
namespace Home\Controller;

use Think\Controller;

class BaseController extends Controller
{
    public $session_id;

    /*
     * 初始化操作
     */
    public function _initialize()
    {
        // 判断当前用户是否手机
        if (isMobile()){
            cookie('is_mobile', '1', 3600);
            header("Location: ".U('Mobile/Index/index'));
        }else{
            cookie('is_mobile', '0', 3600);
        }

        $this->about();
        $this->public_assign();
    }

    //维修介绍
    public function about(){
        $article_id = I('article_id',1245);
        $about = M('article')->where("article_id=$article_id")->find();
        $this->assign('about',$about);
    }

    /**
     * 保存公告变量到 smarty中 比如 导航
     */
    public function public_assign()
    {
        $tpshop_config = array();
        $tp_config = M('config')->cache(true, TPSHOP_CACHE_TIME)->select();
        foreach ($tp_config as $k => $v) {
            if ($v['name'] == 'hot_keywords') {
                $tpshop_config['hot_keywords'] = explode('|', $v['value']);
            }
            $tpshop_config[$v['inc_type'] . '_' . $v['name']] = $v['value'];
        }
        $this->assign('tpshop_config', $tpshop_config);
    }


}